﻿namespace Jhong.FunMVCBlog.Core.Infrastructure
{
    using System.Collections.Generic;

    public class PageContainer<T>
    {
        public int TotalCount { get; private set; }

        public int TotalPage
        {
            get
            {
                if (this.TotalCount % this.ItemsPerPage == 0) return this.TotalCount / this.ItemsPerPage;
                return this.TotalCount / this.ItemsPerPage + 1;
            }
        }

        public int ItemsPerPage { get; private set; }

        public int PageIndex { get; private set; }

        public IList<T> Items { get; set; }

        public PageContainer(int pageIndex, int itemsPerPage, int totalCount, IList<T> items)
        {
            this.PageIndex = pageIndex;
            this.ItemsPerPage = itemsPerPage;
            this.Items = items;
            this.TotalCount = totalCount;
        }
    }
}